//
//  TTTabBarViewController.m
//  Taotao
//
//  Created by Goofy on 9/16/16.
//  Copyright © 2016 ios01. All rights reserved.
//

#import "TTTabBarViewController.h"
#import "TTHomeViewController.h"
#import "TTCategoryViewController.h"
#import "TTCartViewController.h"
#import "TTMineViewController.h"
@interface TTTabBarViewController ()

@end

@implementation TTTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    TTHomeViewController *vc1 = [[TTHomeViewController alloc] init];
    [self addChildViewController:vc1 withImage:nil selectedImage:nil withTittle:@"首页"];
    
    
    TTCategoryViewController *vc2 = [[TTCategoryViewController alloc] init];
    [self addChildViewController:vc2 withImage:nil selectedImage:nil withTittle:@"分类"];
    
    TTCartViewController *vc3 = [[TTCartViewController alloc] init];
    [self addChildViewController:vc3 withImage:nil selectedImage:nil withTittle:@"购物车"];
    
    TTMineViewController *vc4 = [[TTMineViewController alloc] init];
    [self addChildViewController:vc4 withImage:nil selectedImage:nil withTittle:@"我的"];

}




- (void)addChildViewController:(UIViewController *)controller withImage:(UIImage *)image selectedImage:(UIImage *)selectImage withTittle:(NSString *)tittle{
    
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:controller];
    
    [nav.tabBarItem setImage:image];
    
    [nav.tabBarItem setSelectedImage:selectImage];

    controller.title = tittle;
    
    [nav.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor redColor]} forState:UIControlStateSelected];
    
    nav.tabBarItem.titlePositionAdjustment = UIOffsetMake(0, -3);
    
    [self addChildViewController:nav];

}



/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
